--TEST--
string MySQLndUhConnection::escapeString(resource $conn, string $escape_string)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function escapeString($res, $string) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return parent::escapeString($res, $string);
		}
	}

	class proxy2 extends proxy {
		public function escapeString($res, $string) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return str_replace("'", "<proxy>", $string);
		}
	}

	class proxy3 extends proxy {
		public function escapeString($res, $string) {
			return false;
		}
	}

	class proxy4 extends proxy {
		public function escapeString($res, $string) {}
	}

	class proxy5 extends proxy {
		public function escapeString($res, $string) { return str_repeat($string, 3); }
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	var_dump($conn->real_escape_string("test0'test"));

	mysqlnd_uh_set_connection_proxy(new proxy());

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	var_dump($conn->real_escape_string("test1'test"));
	var_dump($conn->real_escape_string("test2'test"));

	mysqlnd_uh_set_connection_proxy(new proxy2());

	var_dump($conn->real_escape_string("test3'test"));
	var_dump($conn->real_escape_string("test4'test"));
	var_dump($conn->real_escape_string(""));

	mysqlnd_uh_set_connection_proxy(new proxy3());
	var_dump($conn->real_escape_string("test5'test"));

	mysqlnd_uh_set_connection_proxy(new proxy4());
	var_dump($conn->real_escape_string("test6'test"));

	mysqlnd_uh_set_connection_proxy(new proxy5());
	var_dump($conn->real_escape_string("test7'test"));

	print "done!";
?>
--EXPECTF--
string(11) "test0\'test"
proxy::escapeString(array (
  0 => NULL,
  1 => 'test1\'test',
))
string(11) "test1\'test"
proxy::escapeString(array (
  0 => NULL,
  1 => 'test2\'test',
))
string(11) "test2\'test"
proxy2::escapeString(array (
  0 => NULL,
  1 => 'test3\'test',
))
string(16) "test3<proxy>test"
proxy2::escapeString(array (
  0 => NULL,
  1 => 'test4\'test',
))
string(16) "test4<proxy>test"
proxy2::escapeString(array (
  0 => NULL,
  1 => '',
))
string(0) ""

Warning: mysqli::real_escape_string(): (MySQLnd User Handler) The method MySQLndUhConnection::escapeString() did not return a string value as it should in %s on line %d

Warning: mysqli::real_escape_string(): (MySQLnd User Handler) The method MySQLndUhConnection::escapeString() did not return a string value as it should in %s on line %d
string(0) ""

Warning: mysqli::real_escape_string(): (MySQLnd User Handler) The method MySQLndUhConnection::escapeString() did not return a string value as it should in %s on line %d

Warning: mysqli::real_escape_string(): (MySQLnd User Handler) The method MySQLndUhConnection::escapeString() did not return a string value as it should in %s on line %d
string(0) ""

Warning: mysqli::real_escape_string(): (MySQLnd User Handler) The method MySQLndUhConnection::escapeString() must not return a string that is more than 2x longer than the input string. Return value will be trimmed to avoid problems in %s on line %d
string(19) "test7'testtest7'tes"
done!